package com.lizhi.yun.core.trainPatient;/**
 * @program: hbsf_yun
 * @name RszTrainPatientHandler
 * @description: 正在训练的患者信息
 * @author: lizhi
 * @create: 2021-11-29 09:46
 */

import com.lizhi.common.yun.entity.ListResponseResult;
import com.lizhi.common.yun.entity.RpcPatientPOJO;
import com.lizhi.utils.StringUtils;
import com.lizhi.utils.cache.MemoryCacheUtil;
import com.lizhi.utils.json.SamJsonUtil;
import com.lizhi.yun.db.rsz.entity.RszPatientEntity;
import com.lizhi.yun.deploy.NewBaseHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 *@program: hbsf_yun
 *@name RszTrainPatientHandler
 *@description: 正在训练的患者信息
 *@author: lizhi
 *@create: 2021-11-29 09:46
 */
@Slf4j
@Service
public class RszTrainPatientHandler extends NewBaseHandler {

    public ListResponseResult doMain(String json){
        Map<String, Object> map = SamJsonUtil.toMap(json);
        String tpId = "";
        if (map.containsKey("hospitalId") && map.containsKey("hospitalSystemId")){
            tpId = map.get("hospitalId").toString() + "-" + map.get("hospitalSystemId").toString();
        }
        if (!StringUtils.isEmpty(tpId)){
            RpcPatientPOJO patient = MemoryCacheUtil.get(tpId);
            log.info("获取到的正在训练的患者信息是:{}", patient);
            return getListResult(patient);
        }
        return getListResult(null, false);
    }
}
